-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also update the docs for how to use the elaborator reflection interface.
- Loading branch information
Alex Humphreys
committed
Jun 27, 2021
1 parent
1e509e1
commit c544b7c
Showing
18 changed files
with
241 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Idrall.API.V2 | ||
|
||
import Idrall.Value | ||
import public Idrall.Expr | ||
import public Idrall.Error | ||
import public Idrall.Derive | ||
import public Idrall.IOEither | ||
import Idrall.APIv1 | ||
|
||
import System.Path -- TODO make public export in System.Directory.Tree? | ||
|
||
liftMaybe : Maybe a -> IOEither Error a | ||
liftMaybe Nothing = MkIOEither $ pure $ Left $ FromDhallError "failed to convert from dhall" | ||
liftMaybe (Just x) = pure x | ||
|
||
export | ||
deriveFromDhallString : FromDhall ty => String -> IOEither Error ty | ||
deriveFromDhallString x = do | ||
e <- roundTripCheckEvalQuote $ x | ||
liftMaybe $ fromDhall e | ||
|
||
export | ||
deriveFromDhallFile : FromDhall a => Path -> IOEither Error a | ||
deriveFromDhallFile = deriveFromDhallString . show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Main | ||
|
||
import Idrall.API.V2 | ||
|
||
import Language.Reflection | ||
%language ElabReflection | ||
|
||
record Package where | ||
constructor MkPackage | ||
package : String | ||
sourceDir : Maybe String | ||
depends : Maybe (List String) | ||
modules : List String | ||
%runElab (deriveFromDhall Record `{{ Package }}) | ||
|
||
Show Package where | ||
show (MkPackage package sourceDir depends modules) = | ||
"MkPackage \{show package} \{show sourceDir} \{show depends} \{show modules}" | ||
|
||
main : IO () | ||
main = do | ||
package <- liftIOEither $ deriveFromDhallString {ty=Package} "./package.dhall" | ||
putStrLn $ show package |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ package = "myidrispackage" | ||
, sourcedir = Some "./" | ||
, depends = Some ["contrib"] | ||
, modules = ["MyIdrisPackage.Main"] | ||
, modules = ["MyIdrisPackage.Main", "MyIdrisPackage.Foo"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ modules = Idrall.Expr | |
, Idrall.Path | ||
, Idrall.TestHelper | ||
, Idrall.APIv1 | ||
, Idrall.API.V2 | ||
, Idrall.Derive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.