This file contains hidden or 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
| #lang racket | |
| (define (quadratic a b c) | |
| (let* ([det (- (* b b) (* 4 a c))] | |
| [x1 (/ (- (sqrt det) b) (* 2 a))] | |
| [x2 (/ (- (- (sqrt det)) b) (* 2 a))]) | |
| (vector x1 x2))) |
This file contains hidden or 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
| module My.Blogs | |
| open System | |
| open System.Collections.Generic | |
| open System.Web | |
| open IntelliFactory.WebSharper.Sitelets | |
| type Id = int | |
| type Html = string |
This file contains hidden or 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
| module Client = | |
| open IntelliFactory.WebSharper | |
| open IntelliFactory.WebSharper.Formlet | |
| [<Rpc>] | |
| let CreateBlog blog = | |
| Model.WithBlogs <| fun db -> | |
| db.CreateBlog { blog with Date = DateTime.UtcNow } | |
| [<Rpc>] |
This file contains hidden or 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
| let Main : Sitelet<Action> = | |
| { | |
| Controller = Controller | |
| Router = Router | |
| } |
This file contains hidden or 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
| let Controller = | |
| let handle = function | |
| | ShowRecentBlogs -> | |
| let blogs = Model.WithBlogs <| fun db -> db.GetRecentBlogs() | |
| View.ShowRecentBlogs blogs | |
| | CreateBlog -> | |
| View.CreateBlog () | |
| | ReadBlog id -> | |
| let blog = Model.WithBlogs <| fun db -> db.ReadBlog id | |
| match blog with |
This file contains hidden or 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
| let Router : Router<Action> = | |
| Router.Table [ShowRecentBlogs, "/"] | |
| <|> Router.Infer() |
This file contains hidden or 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
| ShowRecentBlogs <=> /ShowRecentBlogs | |
| CreateBlog <=> /CreateBlog | |
| ReadBlog $x <=> /ReadBlog/$x | |
| UpdateBlog $x <=> /UpdateBlog/$x | |
| DeleteBlog $x <=> /DeleteBlog/$x | |
This file contains hidden or 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
| let Router : Router<Action> = Router.Infer() |
This file contains hidden or 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
| let Router : Router<Action> = | |
| let route = function | |
| | GET (_, SPLIT_BY '/' []) -> | |
| Some ShowRecentBlogs | |
| | GET (_, SPLIT_BY '/' ["create"]) -> | |
| Some CreateBlog | |
| | GET (_, SPLIT_BY '/' ["read"; INT id]) -> | |
| Some (ReadBlog id) | |
| | GET (_, SPLIT_BY '/' ["update"; INT id]) -> | |
| Some (UpdateBlog id) |
This file contains hidden or 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
| type Id = int | |
| type Action = | |
| | ShowRecentBlogs | |
| | CreateBlog | |
| | ReadBlog of Id | |
| | UpdateBlog of Id | |
| | DeleteBlog of Id |