Last active
August 29, 2015 14:22
-
-
Save nushio3/25b52e6f6365d777bbcd to your computer and use it in GitHub Desktop.
uom-plugin difference
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
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# OPTIONS_GHC -fplugin Data.UnitsOfMeasure.Plugin #-} | |
module Examples where | |
import Data.UnitsOfMeasure | |
import Data.UnitsOfMeasure.Convert | |
import Data.UnitsOfMeasure.Show | |
[u| kg |] | |
myMass = [u| 65.2 kg |] |
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
(7.10.1)nushio@nuwheezy:uom-plugin$ runhaskell Main.hs | |
[u| 65.2 kg |] | |
(7.10.1)nushio@nuwheezy:uom-plugin$ ghci Main.hs | |
GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help | |
[1 of 2] Compiling Examples ( Examples.hs, interpreted ) | |
[2 of 2] Compiling Main ( Main.hs, interpreted ) | |
Ok, modules loaded: Examples, Main. | |
> main | |
[u| 65.2 kg |] | |
> print myMass | |
<interactive>:3:1: | |
No instance for (Data.UnitsOfMeasure.Singleton.KnownUnit | |
(Unpack (Base "kg"))) | |
arising from a use of ‘print’ | |
In the expression: print myMass | |
In an equation for ‘it’: it = print myMass | |
> :seti -fplugin Data.UnitsOfMeasure.Plugin | |
> print myMass | |
[u| 65.2 kg |] | |
> |
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
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# OPTIONS_GHC -fplugin Data.UnitsOfMeasure.Plugin #-} | |
import Data.UnitsOfMeasure | |
import Data.UnitsOfMeasure.Convert | |
import Data.UnitsOfMeasure.Show | |
import Examples | |
main :: IO () | |
main = print myMass |
Solution: to activate the type checker plugin in the GHCi. :seti -fplugin Data.UnitsOfMeasure.Plugin
. As we can see, when we load a .hs
file to GHCi, the plagmas such as type checker plugins and LANGUAGE pragrmas are not activated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wonder why the results of evaluating
main
andprint myMass
differ, given thatmain = print myMass
.