Skip to content

Instantly share code, notes, and snippets.

@Woody88
Last active July 4, 2020 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Woody88/e0dd65012f7c05d89e5286231b284d0e to your computer and use it in GitHub Desktop.
Save Woody88/e0dd65012f7c05d89e5286231b284d0e to your computer and use it in GitHub Desktop.
Refined Example
module Main where
import Prelude
import Data.Either (Either(..))
import Data.Refined (FromTo, Refined, refine, unrefine)
import Data.Typelevel.Num (D0, D100)
import Effect (Effect)
import Effect.Exception (throw)
type PortNumber = Refined (FromTo D0 D100) Int
main :: Effect Unit
main = do
case refine 80 of
Left e -> throw $ show e
Right port -> server port
server :: PortNumber -> Effect Unit
server p = myRealServer (unrefine p)
where
myRealServer :: Int -> Effect Unit
myRealServer _ = pure unit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment