Skip to content

Instantly share code, notes, and snippets.

@monadplus
Created April 9, 2020 11:04
Show Gist options
  • Save monadplus/017d4afa9e57200d5ef392210e8a4e7c to your computer and use it in GitHub Desktop.
Save monadplus/017d4afa9e57200d5ef392210e8a4e7c to your computer and use it in GitHub Desktop.
from Int to Nat
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import GHC.TypeLits
import Data.Proxy
import Data.Maybe
import System.IO
main :: IO ()
main = do
putStrLn "Write an integer"
x <- readLn
printNat $ fromJust (someNatVal x)
printNat :: SomeNat -> IO ()
printNat (SomeNat p) = print . natVal $ p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment