Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Larry Diehl
authored and
Larry Diehl
committed
Apr 26, 2010
1 parent
3803a59
commit e24eb3e
Showing
8 changed files
with
72 additions
and
37 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 |
---|---|---|
|
@@ -8,3 +8,5 @@ | |
*.flymake | ||
*.el | ||
*.agdai | ||
MAlonzo | ||
Runner |
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,45 @@ | ||
module FFI where | ||
import Hack | ||
import Hack.Handler.Happstack as Handler | ||
import Data.ByteString.Lazy.Char8 (pack) | ||
|
||
data Status = | ||
OK | Created | Accepted | NoContent | | ||
MultipleChoices | MovedPermanently | SeeOther | NotModified | MovedTemporarily | | ||
BadRequest | Unauthorized | Forbidden | NotFound | MethodNotAllowed | | ||
NotAcceptable | Conflict | Gone | PreconditionFailed | | ||
RequestEntityTooLarge | RequestURItooLong | UnsupportedMediaType | | ||
NotImplemented | ServiceUnavailable | ||
|
||
fromStatus :: Status -> Int | ||
fromStatus OK = 200 | ||
fromStatus Created = 201 | ||
fromStatus Accepted = 202 | ||
fromStatus NoContent = 204 | ||
fromStatus MultipleChoices = 300 | ||
fromStatus MovedPermanently = 301 | ||
fromStatus SeeOther = 303 | ||
fromStatus NotModified = 304 | ||
fromStatus MovedTemporarily = 307 | ||
fromStatus BadRequest = 400 | ||
fromStatus Unauthorized = 401 | ||
fromStatus Forbidden = 403 | ||
fromStatus NotFound = 404 | ||
fromStatus MethodNotAllowed = 405 | ||
fromStatus NotAcceptable = 406 | ||
fromStatus Conflict = 409 | ||
fromStatus Gone = 410 | ||
fromStatus PreconditionFailed = 412 | ||
fromStatus RequestEntityTooLarge = 413 | ||
fromStatus RequestURItooLong = 414 | ||
fromStatus UnsupportedMediaType = 415 | ||
fromStatus NotImplemented = 501 | ||
fromStatus ServiceUnavailable = 503 | ||
|
||
run :: Status -> IO () | ||
run status = Handler.run $ return . \env -> Response | ||
{ status = code | ||
, headers = [ ("Content-Type", "text/plain") ] | ||
, body = pack ("This HTTP status (" ++ show code ++ ") is brought to you by Lemmachine!") | ||
} | ||
where code = fromStatus status |
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Lemmachine.Runner where | ||
open import Lemmachine | ||
import Lemmachine.Resource.Default as Default | ||
open import Data.Unit | ||
open import Data.Nat | ||
open import Data.String | ||
open import Foreign.Haskell | ||
open import IO.Primitive | ||
|
||
{-# IMPORT FFI #-} | ||
postulate run : Status → IO Unit | ||
{-# COMPILED run FFI.run #-} | ||
|
||
main = run OK -- (resolve (toResource Default.resource)) | ||
|