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
| config :: Config | |
| config = [ooLikeSyntax| | |
| builder <- defaultBuilder | |
| builder#profile | |
| builder#goFaster | |
| builder#extract|] |
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 TemplateHaskell #-} | |
| {-# LANGUAGE QuasiQuotes #-} | |
| {-# LANGUAGE TypeSynonymInstances #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE OverlappingInstances #-} | |
| import Control.Comonad | |
| import Language.Haskell.Codo | |
| type Option = 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
| {-# Language FlexibleInstances, ScopedTypeVariables #-} | |
| class AddNType t where | |
| adds :: Int -> t | |
| instance AddNType Int where | |
| adds = id | |
| instance AddNType t => AddNType (Int -> t) where | |
| adds n = \m -> (adds (n+m) :: t) | |
| addN :: AddNType t => t | |
| addN = adds 0 |
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
| addN :: SNat nat -> NIntArrow nat | |
| addN n = addN' n 0 | |
| where | |
| addN' :: SNat nat -> Int -> NIntArrow nat | |
| addN' SZero acc = acc | |
| addN' (SSucc n') acc = \x -> addN' n' (acc+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
| type family NIntArrow (a :: Nat) | |
| type instance NIntArrow 'Zero = Int | |
| type instance NIntArrow ('Succ n) = Int -> NIntArrow |
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
| data Nat = Zero | Succ Nat | |
| data SNat (n :: Nat) where | |
| SZero :: SNat 'Zero | |
| SSucc :: SNat m -> SNat ('Succ m) |
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 GADTs, KindSignatures, DataKinds, TypeOperators, TypeFamilies #-} | |
| data Nat = Zero | Succ Nat | |
| data SNat (n :: Nat) where | |
| SZero :: SNat 'Zero | |
| SSucc :: SNat m -> SNat ('Succ m) | |
| type family NIntArrow (a :: Nat) | |
| type instance NIntArrow 'Zero = Int | |
| type instance NIntArrow ('Succ n) = Int -> NIntArrow n |
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 GADTs, KindSignatures, DataKinds, TypeOperators, TypeFamilies #-} | |
| data Nat = Zero | Succ Nat | |
| data SNat (n :: Nat) where | |
| SZero :: SNat 'Zero | |
| SSucc :: SNat m -> SNat ('Succ m) | |
| type family NIntArrow (a :: Nat) | |
| type instance NIntArrow 'Zero = Int | |
| type instance NIntArrow ('Succ n) = Int -> NIntArrow n |
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
| import Data.Array.IArray | |
| import Data.Array.Unboxed | |
| sumA :: Array Int Int -> Int | |
| sumA ary = foldl (\acc i -> acc + ary!i) 0 (indices ary) | |
| main = do | |
| let ary = listArray (1, 10) [1..] :: Array Int Int | |
| uary = listArray (1, 10) [1..] :: UArray Int Int | |
| print $ sumA ary |
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
| import Data.Array.IArray | |
| sumA :: Array Int Int -> Int | |
| sumA ary = foldl (\acc i -> acc + ary!i) 0 (indices ary) | |
| main = do | |
| let ary = listArray (1, 10) [1..] :: Array Int Int | |
| print $ sumA ary |